/*
 *  testplan.cpp
 *  Ray Tracing
 *
 *  Created by Jean-Marc Comby + Romain Dequesne on Sat May 01 2004.
 *  Copyright (c) 2004. All rights reserved.
 *
 */

#include "testplan.hpp"

#include "Carreaux.hpp"

#include <boost/assign/list_of.hpp>
#include <boost/foreach.hpp>

using namespace std;
using namespace boost::assign;
using namespace boost;

int main( int argc, char* argv[] )
{
  afficheP();

  return 0;
}

void afficheP()
{
  //titre
  cout << "- Test de la classe Plan -" << endl << endl;
  //definitions
  vector<Coord> Origine; //specs des rayons
  vector<VecteurU> Direction;
  vector<VecteurU> Normale; //specs des plans
  vector<Coord> Passant;
  //init des coord de l'origine
  Origine.push_back(Coord(-1,-2,-3));
  Origine.push_back(Coord(0,0,-2));
  Origine.push_back(Coord(0,0,0));
  Origine.push_back(Coord(0,0,0));
  Origine.push_back(Coord(-1,-2,-3));
  //init des directions
  Direction.push_back(VecteurU(0,0,1));
  Direction.push_back(VecteurU(1,1,1));
  Direction.push_back(VecteurU(1,1,1));
  Direction.push_back(VecteurU(1,1,1));
  Direction.push_back(VecteurU(1,0,0));
  //init des normales des plans
  Normale.push_back(VecteurU(0,0,1));
  Normale.push_back(VecteurU(0,0,1));
  Normale.push_back(VecteurU(1,2,3));
  Normale.push_back(VecteurU(1,2,3));
  Normale.push_back(VecteurU(0,0,1));
  //init des points pas ou passent les plans
  Passant.push_back(Coord(0,0,0));
  Passant.push_back(Coord(1,1,0));
  Passant.push_back(Coord(1,0,0));
  Passant.push_back(Coord(-1,-1,-1));
  Passant.push_back(Coord(0,0,0));
  //affichage des tests
  for (unsigned int i(0); i<Origine.size();i++)
    {
      Plan tempP(Normale[i], Passant[i]);
      Rayon tempr(Origine[i], Direction[i]);
      Coord inters(tempP.intersect(tempr));
      if (inters==NullePart)
	cout << "pas d'intersection" << endl;
      else
	inters.affiche();
    }
  cout << endl << endl;

  Plan tmp( VecteurU( 0., 1., 0. ), Coord( 0., 0. ,0. ) );

  vector< Coord > intr = list_of( Coord( 0.5, 0., -1.5 ) )
    ( Coord( 0.5, 0., -0.5 ) )( Coord( 0.5, 0., 0.5 ) )
    ( Coord( 0.5, 0., 1.5 ) )
    ( Coord( -0.5, 0., -1.5 ) )
    ( Coord( -0.5, 0., -0.5 ) )( Coord( -0.5, 0., 0.5 ) )
    ( Coord( -0.5, 0., 1.5 ) );

  Carreaux carreaux( .6, 0., 1., .5,
		     Couleur( 0, 0, 0 ), Couleur( 255, 255, 255 ), 1. );
  carreaux.volume( &tmp );

  BOOST_FOREACH( Coord c, intr )
    {
      cout << tmp.intrinsequeReduite( c, 1. ) << " => "
	   << carreaux.couleur( c ) << endl;
    }      
}
